package config

import (
	"bytes"
	_ "embed"
	"fmt"

	"github.com/spf13/viper"
)

//go:embed config.yml
var configYAML []byte

func GetConfig(str string) string {
	viper.SetConfigType("yaml")
	if err := viper.ReadConfig(bytes.NewBuffer(configYAML)); err != nil {
		if _, ok := err.(viper.ConfigFileNotFoundError); ok {
			fmt.Println("找不到配置文件..")
		} else {
			fmt.Println("配置文件出错..")
		}
	}

	return viper.GetString(str)
}
